﻿using System.Text;
using System.Xml;

namespace MockingBird.Common.Infrastructure.Helpers
{
    using System.IO;
    using System.Xml.Xsl;
    using MockingBird.Common.Infrastructure.Properties;

    public static class WebBrowserHelper
    {
        public static string GetXml(XmlDocument sourceXmlDoc)
        {
            string xslt = Resources.WebBrowserXsl;
            MemoryStream memStream = new MemoryStream(Encoding.UTF8.GetBytes(xslt));
            XmlReader xReader = XmlReader.Create(memStream);
            XslCompiledTransform xct = new XslCompiledTransform();
            xct.Load(xReader);
            StringBuilder sb = new StringBuilder();
            XmlWriter xWriter = XmlWriter.Create(sb);
            xct.Transform(sourceXmlDoc, xWriter);
            //TBD: dispose the stream?
            return sb.ToString();

        }
    }
}
